package com.ruoyi.project.system.controller;

import java.util.List;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.domain.CollegePaperQuestion;
import com.ruoyi.project.system.service.ICollegePaperQuestionService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 学院组卷题Controller
 * 
 * @author ruoyi
 * @date 2020-11-19
 */
@RestController
@RequestMapping("/system/collegePaperQuestion")
public class CollegePaperQuestionController extends BaseController
{
    @Autowired
    private ICollegePaperQuestionService collegePaperQuestionService;

    /**
     * 查询学院组卷题列表
     */
    @PreAuthorize("@ss.hasPermi('system:collegePaperQuestion:list')")
    @GetMapping("/list")
    public TableDataInfo list(CollegePaperQuestion collegePaperQuestion)
    {
        startPage();
        List<CollegePaperQuestion> list = collegePaperQuestionService.selectCollegePaperQuestionList(collegePaperQuestion);
        return getDataTable(list);
    }

    /**
     * 导出学院组卷题列表
     */
    @PreAuthorize("@ss.hasPermi('system:collegePaperQuestion:export')")
    @Log(title = "学院组卷题", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CollegePaperQuestion collegePaperQuestion)
    {
        List<CollegePaperQuestion> list = collegePaperQuestionService.selectCollegePaperQuestionList(collegePaperQuestion);
        ExcelUtil<CollegePaperQuestion> util = new ExcelUtil<CollegePaperQuestion>(CollegePaperQuestion.class);
        return util.exportExcel(list, "question");
    }

    /**
     * 获取学院组卷题详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:collegePaperQuestion:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(collegePaperQuestionService.selectCollegePaperQuestionById(id));
    }

    /**
     * 新增学院组卷题
     */
    @PreAuthorize("@ss.hasPermi('system:collegePaperQuestion:add')")
    @Log(title = "学院组卷题", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CollegePaperQuestion collegePaperQuestion)
    {
        return toAjax(collegePaperQuestionService.insertCollegePaperQuestion(collegePaperQuestion));
    }

    /**
     * 修改学院组卷题
     */
    @PreAuthorize("@ss.hasPermi('system:collegePaperQuestion:edit')")
    @Log(title = "学院组卷题", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CollegePaperQuestion collegePaperQuestion)
    {
        return toAjax(collegePaperQuestionService.updateCollegePaperQuestion(collegePaperQuestion));
    }

    /**
     * 删除学院组卷题
     */
    @PreAuthorize("@ss.hasPermi('system:collegePaperQuestion:remove')")
    @Log(title = "学院组卷题", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(collegePaperQuestionService.deleteCollegePaperQuestionByIds(ids));
    }
}
